'user strict';//装饰器
angular.module('app').config(['$provide', function ($provide) {
    $provide.decorator('$http', ['$delegate', '$q', function ($delegate, $q) {
        //$delegate此时指代的是$http
        $delegate.post = function (url, data, config) {
           var def =$q.defer();
            $delegate({
                method: 'get',
                url: url
            }).then(function successCallBack(resp) {
                def.resolve(resp.data);
            },function errorCallBack(err) {
                def.reject(err.data)
            });

            return {
                success: function (cb) {
                    def.promise.then(cb);
                },
                error: function (cb) {
                    def.promise.then(null, cb);
                }
            }
        }
        return $delegate;
    }])
}])